package com.xxx.modules.controller;;
import com.xxx.modules.service.MonitorService;
import com.xxx.modules.entity.Monitor;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import com.github.pagehelper.PageInfo;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import com.xxx.modules.utils.Result;
import com.xxx.modules.utils.ResultUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * monitor
 *
 * @author 北易航
 * @since 1.0.0 2023-02-05
 */
@RestController
@RequestMapping("/common/monitor")
@Api(tags="monitor")
public class MonitorController {
    @Autowired
    private MonitorService monitorService;

    /**
    *  获取所有监控信息
    * @param pageNum
    * @param pageSize
    * @param monitor
    * @return
    */

    @GetMapping("/getMonitorInfo")
    @ApiOperation("获取所有监控信息")
    public Result getMonitorInfo(Monitor monitor, @RequestParam(value="pageNum",defaultValue = "1") Integer pageNum,
                                      @RequestParam(value="pageSize",defaultValue = "10") Integer pageSize){
        PageInfo<Monitor> data = monitorService.selectMonitorInfo(monitor,pageNum,pageSize);
        return ResultUtil.success(1,"成功",data);
    }

    /**
    * 保存监控信息
    * @param monitor
    * @return
    */
    @PostMapping("/saveMonitorInfo")
    @ApiOperation("保存监控信息")
    public Result saveMonitorInfo(@RequestBody Monitor monitor){
        monitorService.saveMonitorInfo(monitor);
        return ResultUtil.success(1,"成功",null);
    }


    /**
     * 更新监控信息
     * @param monitor
     * @return
     */

    @PutMapping("/updateMonitorInfo")
    @ApiOperation("更新监控信息")
    public Result updateMonitorInfo(@RequestBody Monitor monitor){
        monitorService.updateMonitorInfo(monitor);
        return ResultUtil.success(1,"成功",null);
    }

    /**
     * 根据id删除监控信息
     * @param id
     * @return
     */
    @DeleteMapping("/delMonitorInfo")
    @ApiOperation("根据id删除监控信息")
    public Result delMonitorInfo(Integer id){
        monitorService.delMonitorInfo(id);
        return ResultUtil.success(1,"成功",null);
    }

    /**
     * 根据id集合批量删除监控信息
     * @param idList
     * @return
     */
    @DeleteMapping("/delBatchMonitorInfo")
    @ApiOperation("根据id集合批量删除监控信息")
    public Result delBatchMonitorInfo(String idList){
        monitorService.delBatchMonitorInfo(idList);
        return ResultUtil.success(1,"成功",null);
    }

}